package com.beetlestech.nfe.main.biz.com.impl;
import java.util.ArrayList;
import java.util.List;

import com.beetlestech.nfe.fw.core.biz.AbstractDBLogic;
import com.beetlestech.nfe.main.biz.com.HbCatagorycName;
import com.beetlestech.nfe.main.biz.com.dto.MstcatagorycInfoDTO;
import com.beetlestech.nfe.main.biz.com.dto.VcourseinfoforteacherInfoDTO;
import com.beetlestech.nfe.main.biz.constant.CommonConstant;
import com.beetlestech.nfe.main.biz.constant.CtgCodeConstant;
import com.beetlestech.nfe.main.biz.constant.HbMessageCode;
import com.beetlestech.nfe.main.db.constant.SQLConstant;
import com.beetlestech.nfe.main.db.tbl.MstcatagorycDTO;
import com.beetlestech.nfe.main.db.view.VcourseinfoforteacherDTO;

public class HbCatagorycNameImpl extends AbstractDBLogic implements HbCatagorycName, CtgCodeConstant, HbMessageCode, CommonConstant, SQLConstant {

	@Override
	public MstcatagorycInfoDTO[] getCatagorycInfoListForAdmin() {
		 MstcatagorycDTO mstcatagorycDTO=new MstcatagorycDTO();
    	 List<MstcatagorycDTO> mstcatagorycDTODBList=new ArrayList<MstcatagorycDTO>();
    	 List<MstcatagorycInfoDTO> mstcatagorycInfoDTOList=new ArrayList<MstcatagorycInfoDTO>();
    	 mstcatagorycDTO.setcatagorypid(Integer.parseInt(CATAGORY_P_ORDER_JURISDICTION.OWNER.toString()));
    	 mstcatagorycDTODBList=queryDAO.queryForObjectList(MstcatagorycDTO.EQUAL_SEARCH,mstcatagorycDTO);
         for (MstcatagorycDTO item : mstcatagorycDTODBList) {
        	 MstcatagorycInfoDTO mstcatagorycInfoDTO=null;
        	 mstcatagorycInfoDTO=convertToMstcatagorycInfoDTO(item);
        	 mstcatagorycInfoDTOList.add(mstcatagorycInfoDTO);
	     }
         return mstcatagorycInfoDTOList.toArray(new MstcatagorycInfoDTO[mstcatagorycInfoDTOList.size()]);
	}
	@Override
	public MstcatagorycInfoDTO[] getCatagorycInfoListForCourseType() {
		MstcatagorycDTO mstcatagorycDTO=new MstcatagorycDTO();
   	 List<MstcatagorycDTO> mstcatagorycDTODBList=new ArrayList<MstcatagorycDTO>();
   	 List<MstcatagorycInfoDTO> mstcatagorycInfoDTOList=new ArrayList<MstcatagorycInfoDTO>();
   	 mstcatagorycDTO.setcatagorypid(Integer.parseInt(CATAGORY_P_COURESE_TYPE.OWNER.toString()));
   	 mstcatagorycDTODBList=queryDAO.queryForObjectList(MstcatagorycDTO.EQUAL_SEARCH,mstcatagorycDTO);
        for (MstcatagorycDTO item : mstcatagorycDTODBList) {
       	 MstcatagorycInfoDTO mstcatagorycInfoDTO=null;
       	 mstcatagorycInfoDTO=convertToMstcatagorycInfoDTO(item);
       	 mstcatagorycInfoDTOList.add(mstcatagorycInfoDTO);
	     }
        return mstcatagorycInfoDTOList.toArray(new MstcatagorycInfoDTO[mstcatagorycInfoDTOList.size()]);
	}
	@Override
	public MstcatagorycInfoDTO[] getCatagorycInfoListForOrderState() {
		
	 MstcatagorycDTO mstcatagorycDTO=new MstcatagorycDTO();
   	 List<MstcatagorycDTO> mstcatagorycDTODBList=new ArrayList<MstcatagorycDTO>();
   	 List<MstcatagorycInfoDTO> mstcatagorycInfoDTOList=new ArrayList<MstcatagorycInfoDTO>();
   	 mstcatagorycDTO.setcatagorypid(Integer.parseInt(CATAGORY_P_ORDER_STATE.OWNER.toString()));
   	 mstcatagorycDTODBList=queryDAO.queryForObjectList(MstcatagorycDTO.EQUAL_SEARCH,mstcatagorycDTO);
        for (MstcatagorycDTO item : mstcatagorycDTODBList) {
       	 MstcatagorycInfoDTO mstcatagorycInfoDTO=null;
       	 mstcatagorycInfoDTO=convertToMstcatagorycInfoDTO(item);
       	 mstcatagorycInfoDTOList.add(mstcatagorycInfoDTO);
	     }
        return mstcatagorycInfoDTOList.toArray(new MstcatagorycInfoDTO[mstcatagorycInfoDTOList.size()]);
	}
	@Override
	public MstcatagorycInfoDTO[] getCatagorycInfoListForCourseState(){
		
		MstcatagorycDTO mstcatagorycDTO=new MstcatagorycDTO();
   	 List<MstcatagorycDTO> mstcatagorycDTODBList=new ArrayList<MstcatagorycDTO>();
   	 List<MstcatagorycInfoDTO> mstcatagorycInfoDTOList=new ArrayList<MstcatagorycInfoDTO>();
   	 mstcatagorycDTO.setcatagorypid(Integer.parseInt(CATAGORY_P_COURSE_STATE.OWNER.toString()));
   	 mstcatagorycDTODBList=queryDAO.queryForObjectList(MstcatagorycDTO.EQUAL_SEARCH,mstcatagorycDTO);
        for (MstcatagorycDTO item : mstcatagorycDTODBList) {
       	 MstcatagorycInfoDTO mstcatagorycInfoDTO=null;
       	 mstcatagorycInfoDTO=convertToMstcatagorycInfoDTO(item);
       	 mstcatagorycInfoDTOList.add(mstcatagorycInfoDTO);
	     }
        return mstcatagorycInfoDTOList.toArray(new MstcatagorycInfoDTO[mstcatagorycInfoDTOList.size()]);
	}
	@Override
	public VcourseinfoforteacherInfoDTO[] getCatagorycInfoListForTeacher(Integer userId) {
		VcourseinfoforteacherDTO vcourseinfoforteacherDTO=new VcourseinfoforteacherDTO();
   	 List<VcourseinfoforteacherDTO> courseinfoforteacherDTODBList=new ArrayList<VcourseinfoforteacherDTO>();
   	 List<VcourseinfoforteacherInfoDTO> courseinfoforteacherInfoDTOList=new ArrayList<VcourseinfoforteacherInfoDTO>();
   	vcourseinfoforteacherDTO.setteacherid(userId);
   	courseinfoforteacherDTODBList=queryDAO.queryForObjectList(VcourseinfoforteacherDTO.EQUAL_SEARCH,vcourseinfoforteacherDTO);
        for (VcourseinfoforteacherDTO item : courseinfoforteacherDTODBList) {
        	VcourseinfoforteacherInfoDTO courseinfoforteacherInfoDTO=null;
        	courseinfoforteacherInfoDTO=convertToVcourseinfoforteacherInfoDTO(item);
        	courseinfoforteacherInfoDTOList.add(courseinfoforteacherInfoDTO);
	     }
        return courseinfoforteacherInfoDTOList.toArray(new VcourseinfoforteacherInfoDTO[courseinfoforteacherInfoDTOList.size()]);
		
	}
	 private MstcatagorycInfoDTO convertToMstcatagorycInfoDTO(MstcatagorycDTO mstcatagorycDTO){
    	 MstcatagorycInfoDTO mstcatagorycInfoDTO =new MstcatagorycInfoDTO();
    	 mstcatagorycInfoDTO.setcatagorycid(mstcatagorycDTO.getcatagorycid());
    	 mstcatagorycInfoDTO.setcatagorycname(mstcatagorycDTO.getcatagorycname());
    	 return mstcatagorycInfoDTO;
     }
	 private VcourseinfoforteacherInfoDTO convertToVcourseinfoforteacherInfoDTO(VcourseinfoforteacherDTO courseinfoforteacherDTO){
		 VcourseinfoforteacherInfoDTO vcourseinfoforteacherInfoDTO =new VcourseinfoforteacherInfoDTO();
		 vcourseinfoforteacherInfoDTO.setcatagorycid(courseinfoforteacherDTO.getcatagorycid());
		 vcourseinfoforteacherInfoDTO.setcatagorycname(courseinfoforteacherDTO.getcatagorycname());
    	 return vcourseinfoforteacherInfoDTO;
     }
	@Override
	public MstcatagorycInfoDTO[] getCatagorycInfoListForLearningState() {
		
		 MstcatagorycDTO mstcatagorycDTO=new MstcatagorycDTO();
	   	 List<MstcatagorycDTO> mstcatagorycDTODBList=new ArrayList<MstcatagorycDTO>();
	   	 List<MstcatagorycInfoDTO> mstcatagorycInfoDTOList=new ArrayList<MstcatagorycInfoDTO>();
	   	 mstcatagorycDTO.setcatagorypid(Integer.parseInt(LEARNING_STATE.OWNER.toString()));
	   	 mstcatagorycDTODBList=queryDAO.queryForObjectList(MstcatagorycDTO.EQUAL_SEARCH,mstcatagorycDTO);
	        for (MstcatagorycDTO item : mstcatagorycDTODBList) {
	        	MstcatagorycInfoDTO mstcatagorycInfoDTO=null;
	        	if(item.getcatagorycid()!=0){
	   	       	 mstcatagorycInfoDTO=convertToMstcatagorycInfoDTO(item);
	   	       	 mstcatagorycInfoDTOList.add(mstcatagorycInfoDTO);
	        	}
	       	 
		     }
	        return mstcatagorycInfoDTOList.toArray(new MstcatagorycInfoDTO[mstcatagorycInfoDTOList.size()]);
		
	}
}
